/** layui-v1.0.3 LGPL license By www.layui.com */

window.onload = function () {
    layui.use('tree', function () {
        var tree = layui.tree({
            elem: '#demo', //指定元素，生成的树放到哪个元素上
            check: 'checkbox', //勾选风格
            skin: 'as', //设定皮肤
            drag: true,//点击每一项时是否生成提示信息
            checkboxName: 'aa[]',//复选框的name属性值
            checkboxStyle: "",//设置复选框的样式，必须为字符串，css样式怎么写就怎么写
            click: function (item) { //点击节点回调
                console.log(item)
            },
            nodes: [ //节点
                {
                    name: '常用文件夹', //节点名称
                    //id: 1,
                    spread: true, //是否是展开状态，true为展开状态
                    // href: "http://www.baidu.com",//设置节点跳转的链接，如果不设置则不会跳转
                    target: "_self",//节点链接打开方式
                    alias: 'changyong',
                    checkboxValue: 1,//复选框的值
                    checked: true,//复选框默认是否选中
                    children: [{
                        name: '所有未读',
                        //id: 11,
                        alias: 'weidu',
                        checked: true,
                        checkboxValue: 2
                    }, {
                        name: '置顶邮件',
                        //id: 12
                    }, {
                        name: '标签邮件',
                        //	id: 13,
                        checked: false,
                        checkboxValue: 3
                    }]
                }, {
                    name: '我的邮箱',
                    //id: 2,
                    checked: true,
                    spread: true,
                    children: [{
                        name: 'QQ邮箱',
                        //	id: 21,
                        checked: true,
                        checkboxValue: 4,
                        spread: true,
                        children: [{
                            name: '收件箱',
                            //id: 211,
                            checked: false,
                            checkboxValue: 5,
                            children: [{
                                name: '所有未读',
                                //	id: 2111,
                                checked: false,
                                checkboxValue: 6,
                                children: [{
                                    name: '一周未读',
                                    //	id: 2111,
                                    checked: false,
                                    checkboxValue: 6
                                }]
                            }, {
                                name: '置顶邮件',
                                //id: 2112,
                                checked: false,
                                checkboxValue: 7
                            }, {
                                name: '标签邮件',
                                id: 2113,
                                checked: false,
                                checkboxValue: 8
                            }]
                        }, {
                            name: '已发出的邮件',
                            //	id: 212,
                            checked: false,
                            checkboxValue: 9
                        }, {
                            name: '垃圾邮件',
                            //id: 213,
                            checked: false,
                            checkboxValue: 10
                        }]
                    }, {
                        name: '阿里云邮',
                        //id: 22,
                        checked: true,
                        checkboxValue: 11,
                        children: [{
                            name: '收件箱',
                            //id: 221,
                            checked: true,
                            checkboxValue: 12
                        }, {
                            name: '已发出的邮件',
                            //id: 222,
                            checked: true,
                            checkboxValue: 13
                        }, {
                            name: '垃圾邮件',
                            //id: 223,
                            checked: true,
                            checkboxValue: 14
                        }]
                    }]
                }
            ]
        });
        //生成一个模拟树
        var createTree = function (node, start) {
            node = node || function () {
                    var arr = [];
                    for (var i = 1; i < 10; i++) {
                        arr.push({
                            name: i.toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
                        });
                    }
                    return arr;
                }();
            start = start || 1;
            layui.each(node, function (index, item) {
                if (start < 10 && index < 9) {
                    var child = [{
                        name: (1 + index + start).toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
                    }];
                    node[index].children = child;
                    createTree(child, index + start + 1);
                }
            });
            return node;
        };

        layui.tree({
            elem: '#demo1' //指定元素
            ,
            nodes: createTree()
        });

    });

};


;!function (e) {
    "use strict";
    var t = function () {
        this.v = "1.0.3"
    };
    t.fn = t.prototype;
    var n = document, o = t.fn.cache = {}, i = function () {
        var e = n.scripts, t = e[e.length - 1].src;
        return t.substring(0, t.lastIndexOf("/") + 1)
    }(), r = function (t) {
        e.console && console.error && console.error("Layui hint: " + t)
    }, u = "undefined" != typeof opera && "[object Opera]" === opera.toString(), l = {
        layer: "modules/layer",
        laydate: "modules/laydate",
        laypage: "modules/laypage",
        laytpl: "modules/laytpl",
        layim: "modules/layim",
        layedit: "modules/layedit",
        form: "modules/form",
        upload: "modules/upload",
        tree: "modules/tree",
        slide: "modules/slide",
        table: "modules/table",
        element: "modules/element",
        util: "modules/util",
        flow: "modules/flow",
        code: "modules/code",
        single: "modules/single",
        mobile: "modules/mobile",
        jquery: "lib/jquery",
        "layui.mod": "dest/layui.mod"
    };
    o.modules = {}, o.status = {}, o.timeout = 10, o.event = {}, t.fn.define = function (e, t) {
        var n = this, i = "function" == typeof e, r = function () {
            return "function" == typeof t && t(function (e, t) {
                layui[e] = t, o.status[e] = !0
            }), this
        };
        return i && (t = e, e = []), layui["layui.all"] ? r.call(n) : (n.use(e, r), n)
    }, t.fn.use = function (e, t, a) {
        function s(e, t) {
            var n = "PLaySTATION 3" === navigator.platform ? /^complete$/ : /^(complete|loaded)$/;
            ("load" === e.type || n.test((e.currentTarget || e.srcElement).readyState)) && (o.modules[y] = t, m.removeChild(p), function i() {
                return ++v > 1e3 * o.timeout / 4 ? r(y + " is not a valid module") : void(o.status[y] ? c() : setTimeout(i, 4))
            }())
        }

        function c() {
            a.push(layui[y]), e.length > 1 ? d.use(e.slice(1), t, a) : "function" == typeof t && t.apply(layui, a)
        }

        var d = this, f = o.dir = o.dir ? o.dir : i, m = n.getElementsByTagName("head")[0];
        e = "string" == typeof e ? [e] : e, window.jQuery && jQuery.fn.on && (d.each(e, function (t, n) {
            "jquery" === n && e.splice(t, 1)
        }), layui.jquery = jQuery);
        var y = e[0], v = 0;
        if (a = a || [], o.host = o.host || (f.match(/\/\/([\s\S]+?)\//) || ["//" + location.host + "/"])[0], 0 === e.length)return t();
        var p = n.createElement("script"), h = (l[y] ? f + "lay/" : o.base || "") + (d.modules[y] || y) + ".js";
        return p.async = !0, p.charset = "utf-8", p.src = h + function () {
                var e = o.version === !0 ? o.v || (new Date).getTime() : o.version || "";
                return e ? "?v=" + e : ""
            }(), o.modules[y] ? !function g() {
            return ++v > 1e3 * o.timeout / 4 ? r(y + " is not a valid module") : void("string" == typeof o.modules[y] && o.status[y] ? c() : setTimeout(g, 4))
        }() : (m.appendChild(p), !p.attachEvent || p.attachEvent.toString && p.attachEvent.toString().indexOf("[native code") < 0 || u ? p.addEventListener("load", function (e) {
            s(e, h)
        }, !1) : p.attachEvent("onreadystatechange", function (e) {
            s(e, h)
        })), o.modules[y] = h, d
    }, t.fn.all = function (e) {
        return this.use("layui.mod", e), this
    }, t.fn.getStyle = function (t, n) {
        var o = t.currentStyle ? t.currentStyle : e.getComputedStyle(t, null);
        return o[o.getPropertyValue ? "getPropertyValue" : "getAttribute"](n)
    }, t.fn.link = function (e, t, i) {
        var u = this, l = n.createElement("link"), a = n.getElementsByTagName("head")[0];
        "string" == typeof t && (i = t);
        var s = (i || e).replace(/\.|\//g, ""), c = l.id = "layuicss-" + s, d = 0;
        l.rel = "stylesheet", l.href = e + (o.debug ? "?v=" + (new Date).getTime() : ""), l.media = "all", n.getElementById(c) || a.appendChild(l), "function" == typeof t && !function f() {
            return ++d > 1e3 * o.timeout / 100 ? r(e + " timeout") : void(1989 === parseInt(u.getStyle(n.getElementById(c), "width")) ? function () {
                t()
            }() : setTimeout(f, 100))
        }()
    }, t.fn.addcss = function (e, t, n) {
        layui.link(o.dir + "css/" + e, t, n)
    }, t.fn.img = function (e, t, n) {
        var o = new Image;
        return o.src = e, o.complete ? t(o) : (o.onload = function () {
            o.onload = null, t(o)
        }, void(o.onerror = function (e) {
            o.onerror = null, n(e)
        }))
    }, t.fn.config = function (e) {
        e = e || {};
        for (var t in e)o[t] = e[t];
        return this
    }, t.fn.modules = function () {
        var e = {};
        for (var t in l)e[t] = l[t];
        return e
    }(), t.fn.extend = function (e) {
        var t = this;
        e = e || {};
        for (var n in e)t[n] || t.modules[n] ? r("模块名 " + n + " 已被占用") : t.modules[n] = e[n];
        return t
    }, t.fn.router = function (e) {
        for (var t, n = (e || location.hash).replace(/^#/, "").split("/") || [], o = {dir: []}, i = 0; i < n.length; i++)t = n[i].split("="), /^\w+=/.test(n[i]) ? function () {
            "dir" !== t[0] && (o[t[0]] = t[1])
        }() : o.dir.push(n[i]), t = null;
        return o
    }, t.fn.data = function (t, n) {
        if (t = t || "layui", e.JSON && e.JSON.parse) {
            if (null === n)return delete localStorage[t];
            n = "object" == typeof n ? n : {key: n};
            try {
                var o = JSON.parse(localStorage[t])
            } catch (i) {
                var o = {}
            }
            return n.value && (o[n.key] = n.value), n.remove && delete o[n.key], localStorage[t] = JSON.stringify(o), n.key ? o[n.key] : o
        }
    }, t.fn.device = function (t) {
        var n = navigator.userAgent.toLowerCase(), o = function (e) {
            var t = new RegExp(e + "/([^\\s\\_\\-]+)");
            return e = (n.match(t) || [])[1], e || !1
        }, i = {
            os: function () {
                return /windows/.test(n) ? "windows" : /linux/.test(n) ? "linux" : /iphone|ipod|ipad|ios/.test(n) ? "ios" : void 0
            }(), ie: function () {
                return !!(e.ActiveXObject || "ActiveXObject" in e) && ((n.match(/msie\s(\d+)/) || [])[1] || "11")
            }(), weixin: o("micromessenger")
        };
        return t && !i[t] && (i[t] = o(t)), i.android = /android/.test(n), i.ios = "ios" === i.os, i
    }, t.fn.hint = function () {
        return {error: r}
    }, t.fn.each = function (e, t) {
        var n, o = this;
        if ("function" != typeof t)return o;
        if (e = e || [], e.constructor === Object) {
            for (n in e)if (t.call(e[n], n, e[n]))break
        } else for (n = 0; n < e.length && !t.call(e[n], n, e[n]); n++);
        return o
    }, t.fn.stope = function (t) {
        t = t || e.event, t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0
    }, t.fn.onevent = function (e, t, n) {
        return "string" != typeof e || "function" != typeof n ? this : (o.event[e + "." + t] = [n], this)
    }, t.fn.event = function (e, t, n) {
        var i = this, r = null, u = t.match(/\(.*\)$/) || [], l = (t = e + "." + t).replace(u, ""), a = function (e, t) {
            var o = t && t.call(i, n);
            o === !1 && null === r && (r = !1)
        };
        return layui.each(o.event[l], a), u[0] && layui.each(o.event[t], a), r
    }, e.layui = new t
}(window);